#ifdef HERZELEID_DESKTOP
 #if _MSC_VER
  #pragma once
 #endif

 #ifndef __HERZELEID_COREAPPLICATION_INCLUDED__
  #define __HERZELEID_COREAPPLICATION_INCLUDED__
  #include "HerzeleidIFrameworkViewSource.hxx"
  #include "HerzeleidSuspendingEventArgs.hxx"
  #include "HerzeleidTypedEvent.hxx"

HerzeleidAppModelCoreNamespaceBegin
	typedef std::vector<CoreApplicationView*> 
		*CoreApplicationViewCollectionPtr,
		CoreApplicationViewCollection;
	typedef std::vector<CoreApplicationView*> const 
		*const CoreApplicationViewCollectionViewPtr,
		CoreApplicationViewCollectionView;
HerzeleidAppModelCoreNamespaceEnd

HerzeleidAppModelCoreNamespaceBegin class CoreApplication // Enables apps to handle state changes, manage windows, and integrate with a variety of UI frameworks.
{
	// Internal type system

	typedef HerzeleidFoundationNamespaceImpl::TypedEvent<Object, HerzeleidAppModelNamespaceImpl::SuspendingEventArgs> SuspendingEvent;
	typedef HerzeleidFoundationNamespaceImpl::TypedEvent<Object, Object> ResumingEvent, ExitingEvent;
	typedef HerzeleidAppModelNamespaceImpl::SuspendingEventArgs SuspendingEventArgs;
	typedef Concurrency::cancellation_token_source AsyncCancellationTokenSource;							// Represents an asynchronous cancellation token source.
	typedef Concurrency::cancellation_token AsyncCancellationToken;											// Represents an asynchronous cancellation token.
	typedef Concurrency::task_canceled AsyncActionCanceledError;											// Represents an asynchronous task cancelled exception.
	typedef Concurrency::task<Bool> AsyncAction;															// Represents an asynchronous cancellable action.
	TinyTypeDecl( AsyncActionCanceledError );																// Represents an asynchronous task cancelled exception.
	TinyTypeDecl( SuspendingEventArgs ); 
	TinyTypeDecl( SuspendingEvent ); 
	TinyTypeDecl( ResumingEvent ); 
	TinyTypeDecl( ExitingEvent ); 
	TinyTypeDecl( AsyncAction ); 

	typedef std::exception Error;																			// Represents an standard exception.
	TinyTypeDecl( Error );																					// Represents an standard exception.

public:

	~CoreApplication( );

	// Gets application view collection ptr. 
	static CoreApplicationViewCollectionViewPtr Views(); // NOTE: Static properties are not allowed :(
	// Gets main application view ptr. 
	static CoreApplicationViewPtr MainView(); // NOTE: Static properties are not allowed :(

	static CoreApplication *Startup( _In_ InstanceHandleConstRef hInstance );
	static Void Exit();

	// Runs an external view provider factory to obtain a view provider.
	static void Run( 
		_In_ IFrameworkViewSourcePtr pViewSrc					// An implementation of a view provider factory.
		);

	//static SuspendingEvent	Suspending;							// Occurs when the app is suspending.
	//static ResumingEvent		Resuming;							// Occurs when an app is resuming.
	//static ExitingEvent		Exiting;							// Occurs when the app is shutting down

owned_access:

	InstanceHandle m_hInst;
	static CoreApplicationViewCollection s_vApplicationViews;
	static CoreApplication *s_pApplicationInstance;
	//static AsyncCancellationTokenSource *s_MessageLoopCancellationHandle;
	static AsyncAction *s_MessageLoopHandle;

	CoreApplication( _In_ InstanceHandleConstRef hInstance );

} HerzeleidAppModelCoreNamespaceEnd; 

 #endif // !HERZELEID_COREAPPLICATION_INCLUDED__
#endif // !HERZELEID_DESKTOP
